feat: add WASM-based DOT transaction parsing via @bitgo/wasm-dot#8074
feat: add WASM-based DOT transaction parsing via @bitgo/wasm-dot#8074
Conversation
8f026fb to
93666ed
Compare
25ff6c2 to
9573f45
Compare
158a9ee to
5a95281
Compare
a6c6162 to
37c8882
Compare
25b65b8 to
40b3425
Compare
e665796 to
70a9662
Compare
| // the input source is the proxy address, not the sender). Otherwise, mirror | ||
| // outputs with sender as the default input source. | ||
| const inputs: InternalInput[] = | ||
| analysis.inputs ?? (sender ? analysis.outputs.map((o) => ({ address: sender, value: o.amount })) : []); |
There was a problem hiding this comment.
Complex single-line expression combining nullish coalescing and an inline ternary/map makes the intent hard to parse; split the defaulting and mapping into separate statements.
Details
✨ AI Reasoning
A single expression was added that uses nullish coalescing with an embedded ternary mapping expression. This combines multiple decision points and an inline map callback that returns an object. That increases cognitive load when reading the assignment because the defaulting logic and mapping behavior must be mentally composed in one line.
🔧 How do I fix it?
Break long lines to enhance clarity. Aim for a maximum of 80-120 characters per line, depending on the context and coding standards.
Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
Adds explainDotTransaction() using @bitgo/wasm-dot for parsing DOT transactions. Includes proxy deposit cost handling for batch stake/unstake explanations, high-level intent test migration, and wasm-dot bumped to ^1.5.0 for unsigned tx blake2b IDs. Ticket: BTC-3062
| // Use explicit inputs from analysis if provided (e.g., unstake batch where | ||
| // the input source is the proxy address, not the sender). Otherwise, mirror | ||
| // outputs with sender as the default input source. | ||
| const inputs: InternalInput[] = |
There was a problem hiding this comment.
Complex expression mixes nullish coalescing, ternary, and inline map. Split into named intermediate variables to clarify fallback and mapping.
Details
✨ AI Reasoning
The expression assigns inputs using a nullish coalescing with a ternary fallback that itself contains a map callback with an inline object construction. This mixes multiple decision operators (? : and ??) and an inline map in one expression, increasing cognitive load when reading or debugging. Extracting the ternary/map into named intermediate steps would make intent and data flow clearer. I am confident because the line combines a nullish coalescing, a ternary conditional, and a mapping callback in one expression.
🔧 How do I fix it?
Break long lines to enhance clarity. Aim for a maximum of 80-120 characters per line, depending on the context and coding standards.
Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
Integrates @bitgo/wasm-dot into sdk-coin-dot for WASM-based transaction
parsing using Rust/subxt, replacing the JS txwrapper-polkadot path for
tdot (testnet) signed transactions.
what changed
wasmParser.ts: new module with
explainDotTransaction()andtoJsonFromWasm()that parse DOT extrinsics via WASM and map toBitGoJS TransactionExplanation / TxData formats. handles transfers,
staking (bond, unbond, withdraw, chill, payout), proxy (add/remove),
batch (nested + atomic), and transferAll.
transaction.ts toJson(): signed tdot transactions now use the WASM
path (
toJsonFromWasm), which handles metadata-aware signed extensionparsing (e.g. Westend's AuthorizeCall, StorageWeightReclaim). unsigned
transactions still use the legacy txwrapper path.
webpack config: added ESM alias for @bitgo/wasm-dot so browser
builds use the fetch-based WASM loader instead of fs.readFileSync.
tests: 72+ new test lines in dot.ts covering WASM explain for
transfers and staking. 511-line byte comparison test suite validating
WASM builder output matches legacy txwrapper output byte-for-byte
across all transaction types (transfer, stake, unstake, withdraw,
chill, proxy, batch).
withdrawUnstakedBuilder test fix: numSlashingSpans assertion
updated from string to number to match actual type.
scope
WASM path is only active for tdot signed transactions, gated by
this._coinConfig.name === 'tdot' && this._signedTransaction. mainnetdot remains on the legacy path until validation is complete.
TICKET: BTC-3068